<template>
	<view class="page-bg">
		<!-- user -->
		<view class="user-info">
			<view class="avatar">
				<image
					:src="userInfo.avatar || 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'"
					mode="aspectFit"></image>
			</view>
			<view class="info">
				<view class="bg">{{ userInfo.nickName || '暂未昵称' }}</view>
				<view class="sm">联系方式：{{ userInfo.phone || '暂未设置' }}</view>
				<view class="sm">注册时间：{{ userInfo.createTime }}</view>
				<uni-icons class="icon" type="gear" size="30" @click="goSetting"></uni-icons>
			</view>
		</view>
		<!-- task -->
		<view class="task-box">
			<view class="grid-item-box" v-for="(item, index) in functionList" :index="index" :key="index"
				@click="handleOrder(item)">
				<uni-icons color="#CE5661" custom-prefix="iconfont" :type="item.type" size="30"></uni-icons>
				<text class="text">{{ item.title }}</text>
			</view>
		</view>
		<!-- order -->
		<view class="order">
			<view @click="handleOrder(item)" class="order-item" v-for="item in orderList" :key="item.title">
				<text>{{ item.title }}</text>
				<uni-icons type="right" size="26"></uni-icons>
			</view>
		</view>
	</view>
</template>

<script setup>
import { ref } from 'vue';
import { getProfile } from '@/api/user.js'
import { onShow } from "@dcloudio/uni-app"

const userInfo = ref({
	avatar: '',
	nickName: '',
	gender: 0,
	phone: '',
	address: '',
	email: ''
})

onShow(() => getProfileData())

const getProfileData = async () => {
	const { data } = await getProfile()
	userInfo.value = data
}

const functionList = ref([
	{
		type: "icon-zaixiankefu",
		title: "待接单",
		path: '/pages/order-info/index?status=0&name=待接单'
	},
	{
		type: "icon-a-jianqu61",
		title: "已接单",
		path: '/pages/order-info/index?status=1&name=已接单'
	},
	{
		type: "icon-fuli",
		title: "已完成",
		path: '/pages/order-info/index?status=2&name=已完成'
	},
	{
		type: "icon-dingdan_dingdanleixingshezhi",
		title: "已移交",
		path: '/pages/order-info/index?status=3&name=已移交'
	}
])
const orderList = ref([
	{
		title: '提交订单',
		path: '/pages/submit-order/submit-order'
	},
	{
		title: '可结算订单',
		path: '/pages/settleable-order/settleable-order'
	},
	{
		title: '无法结算订单',
		path: '/pages/no-settleable-order/no-settleable-order'
	}
])
const handleOrder = (item) => {
	uni.navigateTo({
		url: item.path
	})
}
const goSetting = () => {
	uni.navigateTo({
		url: '/pages/agency-my/setting-account'
	})
}
</script>

<style lang="scss" scoped>
.user-info {
	box-sizing: border-box;
	height: 300rpx;
	width: 100%;
	background: linear-gradient(to right, #f6e4e5 0%, #fff 20%, #fefcfd 70%, #f6e4e5 100%);
	display: flex;
	align-items: center;
	padding: 0 40rpx;

	.avatar {
		width: 200rpx;
		height: 200rpx;
		border-radius: 100rpx;

		image {
			height: 100%;
			width: 100%;
			border-radius: 100rpx;
		}
	}

	.info {
		flex: 1;
		display: flex;
		flex-direction: column;
		margin-left: 30rpx;
		position: relative;

		.bg {
			width: 300rpx;
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
			font-size: 50rpx;
			padding-bottom: 30rpx;
		}

		.sm {
			font-size: 24rpx;
		}

		.icon {
			position: absolute;
			top: 0rpx;
			right: 10rpx;
		}
	}
}

.task-box {
	width: 96%;
	display: flex;
	margin: 30rpx auto;
	padding: 12rpx 0;
	font-size: 24rpx;
	justify-content: space-around;
	border-radius: 40rpx;
	box-shadow: 0rpx 0rpx 4rpx rgba(0, 0, 0, 0.3);

	.grid-item-box {
		width: 160rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		padding: 30rpx 0;
		margin: 6rpx;
		height: 60rpx;
		border-radius: 10rpx;

		text {
			margin-top: 10rpx;
		}
	}
}

.order {
	.order-item {
		width: 94%;
		box-sizing: border-box;
		height: 80rpx;
		border: 1rpx solid $brand-theme-color;
		border-radius: 16rpx;
		margin: 40rpx auto;
		padding: 0 30rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;

		:deep(.uni-icons) {
			color: $brand-theme-color !important;
		}
	}
}
</style>
